﻿//-----------------------------------------------------------------------------
// <copyright file="IServiceRegistry.cs" company="William E. Kempf">
//     Copyright (c) William E. Kempf.
// </copyright>
//-----------------------------------------------------------------------------

namespace Onyx.ComponentModel
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Diagnostics.CodeAnalysis;
using Onyx.Windows;

    /// <summary>
    /// Defines a type that can be used to create a service provider.
    /// </summary>
    public interface IServiceRegistry
    {
        /// <summary>
        /// Adds the specified service to the service container.
        /// </summary>
        /// <param name="serviceType">The type of service to add.</param>
        /// <param name="serviceInstance">An instance of the service type to add. This object must implement or inherit from the type indicated by the <paramref name="serviceType"/> parameter.</param>
        void RegisterService(Type serviceType, object serviceInstance);

        /// <summary>
        /// Adds the specified service to the service registry.
        /// </summary>
        /// <param name="serviceType">The type of service to add.</param>
        /// <param name="callback">A callback object that is used to create the service. This allows a service to be declared as available, but delays the creation of the object until the service is requested.</param>
        void RegisterService(Type serviceType, Func<IServiceProvider, Type, object> callback);

        void RegisterServicesFor(object serviceProvider);

        /// <summary>
        /// Gets a service provider configured with the services registered on this instance.
        /// </summary>
        /// <returns>
        /// An <see cref="IServiceProvider"/> configured with the services registered on this instance.
        /// </returns>
        IServiceProvider CreateServiceProvider();
    }
}
